package com.sinaapp.mrblog.game.Assasin.model;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.sinaapp.mrblog.game.Assasin.stage.GameStage;
import com.sinaapp.mrblog.game.Assasin.util.AssasinConst;
import com.sinaapp.mrblog.game.Assasin.util.AssasinManager;

public class Timebar extends BaseActor {

	public static final float TIMEBAR_WIDTH = 4;
	public static final float TIMEBAR_HEIGHT = 2;
	public static final float TIME_LENGTH = 3;

	public static float time;
	public static String timeStr;

	public Timebar(float x, float y) {
		super(x, y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT);

		AssasinManager.font.setScale(TIMEBAR_WIDTH / TIME_LENGTH
				/ (AssasinConst.TIMEBAR_NUMBER_SIZE - TIME_LENGTH),
				TIMEBAR_HEIGHT / AssasinConst.TIMEBAR_NUMBER_SIZE);
	}

	@Override
	public void act(float delta) {
		time -= delta;
		int seconds = (int) time;
		if (seconds > 99) {
			timeStr = Integer.toString(seconds);
		} else if (9 < seconds) {
			timeStr = "0" + Integer.toString(seconds);
		} else {
			timeStr = "00" + Integer.toString(seconds);
			if (seconds < 0) {
				GameStage.getStage().setState(GameStage.STAGE_OVER);
			}
		}
	}

	@Override
	public void draw(SpriteBatch batch, float parentAlpha) {
		AssasinManager.font.draw(batch, timeStr, getX(), getY());
	}

	@Override
	public void refreshStatus() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public TextureRegion getReadyRegion() {
		// TODO Auto-generated method stub
		return region;
	}
}
